var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { promises as _promises } from 'fs';
const { stat } = _promises;
export const getFileExtension = (filename) => {
    return filename.substring(filename.lastIndexOf('.') + 1, filename.length) || filename;
};
export const isFileSizeValid = (path, maxFileSizeInMb) => __awaiter(void 0, void 0, void 0, function* () {
    const maxFileSizeBytes = maxFileSizeInMb * 1000000;
    const stats = yield stat(path);
    return stats.size <= maxFileSizeBytes;
});
export function isError(obj) {
    return Object.prototype.toString.call(obj) === '[object Error]';
}
